package com.stone.jvm;

import java.nio.ByteBuffer;
import java.util.Scanner;

/**
 * 查看直接内存的占用与释放
 */
public class DirectMemoryDemo {

    public static void main(String[] args) {
        // 直接分配本地内存空间 - 1GB
        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024 * 1024 * 1024);
        System.err.println("分配直接内存！");

        Scanner scanner = new Scanner(System.in);
        scanner.next();

        System.err.println("释放直接内存");
        byteBuffer = null;
        System.gc();
        scanner.next();

    }

}
